import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编码',
    align:"center",
    sorter: true,
    dataIndex: 'organizationCode'
   },
   {
    title: '名称',
    align:"center",
    dataIndex: 'organizationName'
   },
   {
    title: '类型',
    align:"center",
    sorter: true,
    customRender: ({ text }) => {
      return render.renderDict(text.organizationType, 'organization_category');
    },
   },
   {
    title: '第三方编码',
    sorter: true,
    align:"center",
    dataIndex: 'thirdPartyCode'
   },
   {
    title: '地址',
    align:"center",
    dataIndex: 'organizationAddress'
   },
   {
    title: '电话',
    align:"center",
    dataIndex: 'enterprisePhone'
   },
   {
    title: '邮箱',
    align:"center",
    dataIndex: 'enterpriseMailbox'
   },
   {
    title: '税号',
    align:"center",
    dataIndex: 'enterpriseNumber'
   },
   {
    title: '开户名',
    align:"center",
    dataIndex: 'enterpriseAccountName'
   },
   {
    title: '开户行',
    align:"center",
    dataIndex: 'enterpriseBank'
   },
   {
    title: '开户账号',
    align:"center",
    dataIndex: 'accountNumber'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'organizationCode',
    label: '编码',
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    field: 'organizationName',
    label: '名称',
    component: 'Input',
    colProps: { span: 12 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编码',
    field: 'organizationCode',
    component: 'Input',
    slot: 'codeSlot',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入编码!'},
          ];
     },
  },
  {
    label: '名称',
    field: 'organizationName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入名称!'},
          ];
     },
  },
  {
    label: '类型',
    field: 'organizationType',
    component: 'JDictSelectTag',
    defaultValue: 1,
    componentProps:{
        dictCode:"organization_category",
        stringToNumber: true,
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入类型!'},
          ];
     },
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
  },
  {
    label: '地址',
    field: 'organizationAddress',
    component: 'Input',
  },
  {
    label: '电话',
    field: 'enterprisePhone',
    component: 'Input',
    rules: [{
      pattern: /^((0\d{2,3}(-)?\d{7,8})|(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8})$/,
      message: '请输入正确的电话'
    }],
  },
  {
    label: '邮箱',
    field: 'enterpriseMailbox',
    component: 'Input',
    rules: [{ required: false, type: 'email', message: '邮箱格式不正确', trigger: 'blur' }],
    componentProps: {
      placeholder: '请输入邮箱',
    },
  },
  {
    label: '税号',
    field: 'enterpriseNumber',
    component: 'Input',
  },
  {
    label: '开户名',
    field: 'enterpriseAccountName',
    component: 'Input',
  },
  {
    label: '开户行',
    field: 'enterpriseBank',
    component: 'Input',
  },
  {
    label: '开户账号',
    field: 'accountNumber',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}